package net.intellect.collectPro.main;

import java.rmi.RemoteException;
import java.util.logging.Level;
import java.util.logging.Logger;

import net.intellect.collectPro.businessLogic.payments.PaymentAssignment;
import net.intellect.force.ClientSalesforce;

import com.sforce.soap.enterprise.InvalidIdFault;
import com.sforce.soap.enterprise.LoginFault;
import com.sforce.soap.enterprise.UnexpectedErrorFault;

public class PaymentAssignmentProcess {

	protected static Logger logger = Logger.getLogger("payments");
	

	/**
	 * Executes the Assignment process. 
	 * @param args [user, password, token, enterprise]
	 */
	public static void main(String[] args) throws UnexpectedErrorFault, InvalidIdFault, LoginFault, RemoteException, Exception{
		logger.getLevel();
		if (args.length == 4) {
			String userName = args[0]; 
			String password = args[1]; 
			String token = args[2]; 
			String enterprise = args[3]; 
	
			try {
				logger.log(Level.INFO, "PaymentAssignmentProcess - Open for business");
				if (null != userName && null != password && null != token && null != enterprise) {
					ClientSalesforce.setLoginValues(userName,password,token);
					ClientSalesforce.login();
					PaymentAssignment payAssingment = new PaymentAssignment();
					payAssingment.assingPayments(enterprise);
				}
			} catch (Exception e) {
				logger.log(Level.SEVERE, "net.intellect.collectPro.main.PaymentAssignmentProcess/"+"Error: " + e);
			}
		} else {
			logger.log(Level.SEVERE, "net.intellect.collectPro.main.PaymentAssignmentProcess/"+"Required information was not received");
		}
	}

}
